<?php
if(!defined('IN_KKFRAME')) exit();
if(!$uid) showmessage('请先登陆', 'member.php?do=login');

$allow_type = array('.jpg', '.png', '.gif');
if($_FILES['avatar'] && $_FILES['avatar']['error'] <= 0){
	if(filesize($_FILES['csv']['tmp_name']) > 51200) showmessage('图片大小已超过 50 KB，请压缩后再上传', referer());
	$suffix = strtolower(substr($_FILES['avatar']['name'], '-4'));
	if(!in_array($suffix, $allow_type)) showmessage('图片文件格式不符合要求，请自行转换为常用格式', referer());
	@copy($_FILES['avatar']['tmp_name'], ROOT."data/avatar/{$uid}{$suffix}");
	showmessage('上传成功！', referer(), 0);
}

include template('avatar');